package com.miage.http;

import org.apache.log4j.Logger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.net.Socket;

/**
 * @author ilyass lamrani
 * @author Mohamed solaani
 * @version 0.1
 */
public class DebugHeaders {
	/** le Logger de cette classe. */
	private static final Logger LOG = Logger.getLogger(DebugHeaders.class);

	/**
	 * Creates a new DebugHeaders.
	 *
	 * @param connexion
	 *            .
	 */
	public DebugHeaders(final Socket connexion) {
		try {
			BufferedReader bReader = new BufferedReader(new InputStreamReader(
					connexion.getInputStream()));

			if (LOG.isDebugEnabled()) {
				LOG.debug("DebugHeaders(Socket) - ---------FILE--------");
			}

			while (bReader.ready()) {
				if (LOG.isDebugEnabled()) {
					LOG.debug("DebugHeaders(Socket) - " + bReader.readLine());
				}
			}

			if (LOG.isDebugEnabled()) {
				LOG.debug("DebugHeaders(Socket) - ---------END--------");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			LOG.error("DebugHeaders(Socket)", e); //$NON-NLS-1$
		}
	}
}
